package com.zjz.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ControllerTest4 {

    // 原来的方式；add?a=1&b=2
    // RestFul方式：add/a/b

    @RequestMapping("/add/{a}/{b}")
    public String test1(@PathVariable int a, @PathVariable int b, Model model){
        int res = a+b;
        model.addAttribute("msg","结果为："+res);
        if(res == 5){
            return "redirect:test.jsp";
        }else {
            return "/admin/test";
        }

    }
}
